package com.ruoyi.web.controller.work;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.work.domain.vo.WorkSubmitQuery;
import com.ruoyi.work.service.IWorkSubmitQueryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * @Author: MMDZ
 * @Desc: TODO 提报查询
 */
@RestController
@RequestMapping("/work/search")
public class WorkSubmitQueryController extends BaseController {

    @Autowired
    private IWorkSubmitQueryService workSubmitQueryService;

    /**
     * 提报查询列表
     *
     * @param search
     * @return
     */
    @PreAuthorize("@ss.hasPermi('work:search:list')")
    @GetMapping("/list")
    public TableDataInfo list(WorkSubmitQuery search) {
        startPage();
        List<WorkSubmitQuery> list = workSubmitQueryService.selectWorkSubmitQuery(search);
        return getDataTable(list);
    }

    /**
     * 导出
     *
     * @param response
     * @param search
     */
    @PreAuthorize("@ss.hasPermi('work:search:export')")
    @Log(title = "导出提报查询", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WorkSubmitQuery search) {
        List<WorkSubmitQuery> list = workSubmitQueryService.selectWorkSubmitQuery(search);
        ExcelUtil<WorkSubmitQuery> util = new ExcelUtil<WorkSubmitQuery>(WorkSubmitQuery.class);
        util.exportExcel(response, list, "提报查询数据");
    }

}
